<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <script>
        // 数组的创建
        // 1. new Array();
        var array = new Array();
        // 2. []
        var arr = [];
        var arr1 = [1, 2, 3, 'haha', true];

        for (let index = 0; index < arr1.length; index++) {
            console.log(arr1[index]);
        }

        // 数组转换字符串
        console.log(arr1.join('-'));

        // 修改数组长度
        // 1. 直接修改数组长度
        arr2 = [1, 2, 3];
        console.log(arr2.length);
        arr2.length = 5;
        console.log(arr2);
        console.log(arr2[3]);
        console.log(arr2[4]);
        arr2[3] = 4;
        console.log(arr2);

        // 2. 追加数组元素
        arr3 = [1, 2, 3];
        arr3[10] = 4;
        arr3[0] = 'haha ';
        console.log(arr3);
        console.log(arr3.join(','));
    </script>

</head>

<body>

</body>

</html>